"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

require("core-js/modules/es.array.concat");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _events = _interopRequireDefault(require("events"));

/*
 * Copyright (C) 2016 Bilibili. All Rights Reserved.
 *
 * @author zheng qian <xqq@xqq.im>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var Log = /*#__PURE__*/function () {
  function Log() {
    (0, _classCallCheck2.default)(this, Log);
  }

  (0, _createClass2.default)(Log, null, [{
    key: "e",
    value: function e(tag, msg) {
      if (!tag || Log.FORCE_GLOBAL_TAG) tag = Log.GLOBAL_TAG;
      var str = "[".concat(tag, "] > ").concat(msg);

      if (Log.ENABLE_CALLBACK) {
        Log.emitter.emit('log', 'error', str);
      }

      if (!Log.ENABLE_ERROR) {
        return;
      }

      if (console.error) {
        console.error(str);
      } else if (console.warn) {
        console.warn(str);
      } else {
        console.log(str);
      }
    }
  }, {
    key: "i",
    value: function i(tag, msg) {
      if (!tag || Log.FORCE_GLOBAL_TAG) tag = Log.GLOBAL_TAG;
      var str = "[".concat(tag, "] > ").concat(msg);

      if (Log.ENABLE_CALLBACK) {
        Log.emitter.emit('log', 'info', str);
      }

      if (!Log.ENABLE_INFO) {
        return;
      }

      if (console.info) {
        console.info(str);
      } else {
        console.log(str);
      }
    }
  }, {
    key: "w",
    value: function w(tag, msg) {
      if (!tag || Log.FORCE_GLOBAL_TAG) tag = Log.GLOBAL_TAG;
      var str = "[".concat(tag, "] > ").concat(msg);

      if (Log.ENABLE_CALLBACK) {
        Log.emitter.emit('log', 'warn', str);
      }

      if (!Log.ENABLE_WARN) {
        return;
      }

      if (console.warn) {
        console.warn(str);
      } else {
        console.log(str);
      }
    }
  }, {
    key: "d",
    value: function d(tag, msg) {
      if (!tag || Log.FORCE_GLOBAL_TAG) tag = Log.GLOBAL_TAG;
      var str = "[".concat(tag, "] > ").concat(msg);

      if (Log.ENABLE_CALLBACK) {
        Log.emitter.emit('log', 'debug', str);
      }

      if (!Log.ENABLE_DEBUG) {
        return;
      }

      if (console.debug) {
        console.debug(str);
      } else {
        console.log(str);
      }
    }
  }, {
    key: "v",
    value: function v(tag, msg) {
      if (!tag || Log.FORCE_GLOBAL_TAG) tag = Log.GLOBAL_TAG;
      var str = "[".concat(tag, "] > ").concat(msg);

      if (Log.ENABLE_CALLBACK) {
        Log.emitter.emit('log', 'verbose', str);
      }

      if (!Log.ENABLE_VERBOSE) {
        return;
      }

      console.log(str);
    }
  }]);
  return Log;
}();

Log.GLOBAL_TAG = 'flv.js';
Log.FORCE_GLOBAL_TAG = false;
Log.ENABLE_ERROR = true;
Log.ENABLE_INFO = true;
Log.ENABLE_WARN = true;
Log.ENABLE_DEBUG = true;
Log.ENABLE_VERBOSE = true;
Log.ENABLE_CALLBACK = false;
Log.emitter = new _events.default();
var _default = Log;
exports.default = _default;